﻿@model IEnumerable<HanGu.Entity.Message>
@{
    Layout = null;
    int i = 1;
    ViewBag.ViewTitle = "联系记录";
    var SearchParma = ViewData["SearchParma"] as HanGu.Entity.UniversallySearchParam;
    var members = ViewData["members"] as SelectList;
    var AccessCusType = ViewData["AccessCusType"] as SelectList;
    var update = ViewData["update"] as HanGu.Entity.VRolePurview;
    var reSend = ViewData["reSend"] as HanGu.Entity.VRolePurview;
    var goSend = ViewData["goSend"] as HanGu.Entity.VRolePurview;
}
<form id="pagerForm" method="get" action="/Message/Default/index?action=page&OpID=@ViewData["OperateID"]">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
<input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
<input type="hidden" name="orderField" value="${param.orderField}" />
<input type="hidden" name="Ttile" value="@SearchParma.Ttile" />
<input type="hidden" name="IntObj2" value="@SearchParma.IntObj2" />
<input type="hidden" name="IntObj1" value="@SearchParma.IntObj1" />
<input type="hidden" name="StarTime" value="@SearchParma.StarDateTime" />
<input type="hidden" name="EndTime" value="@SearchParma.EndDateTime" />
<script>
    $(function () { 
    $("#Form_@ViewData["CurrentController"] #IntObj1").val("@SearchParma.IntObj1");
    $("#Form_@ViewData["CurrentController"] #IntObj2").val("@SearchParma.IntObj2");
    });

    function Deleting(id)
    {      
        var $this=$(".delete,.Message_id");
        var oHref=$this.attr("rev");
        if(oHref==null || oHref.length==0)
        {
            oHref=$this.attr("href");
            $this.attr("rev",oHref);
        }            
        $this.attr("href",oHref.replace("{Message_id}",id));
    }
</script>
</form>
<div class="pageHeader">
    <form onsubmit="return navTabSearch(this);" id="Form_@ViewData["CurrentController"]" action="/Message/Default/index?action=search&OpID=@ViewData["OperateID"]"
    method="post">
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>
                    类型：
                </td>
                <td>
                    @Html.DropDownList("IntObj1", AccessCusType, HanGu.CRM.HelperCommon.SelectDefaultValue, new { @class = "combox" })
                </td>
                @*<td>
                    会员：
                </td>
                <td>
                    @Html.DropDownList("IntObj2", members, new { @class = "combox" })
                </td>*@
                <td>
                    关键字：
                </td>
                <td>
                    @Html.TextBox("Title", SearchParma.Ttile)
                </td>
                <td style="width: 100px;">
                    更新时间:
                </td>
                <td style="width: 120px;">
                    <p style="width: 110px;">
                        @Html.TextBox("StarTime", SearchParma.StarDateTime, new { @class = "date", format = "yyyy-MM-dd HH:mm", @readonly = "true" })
                    </p>
                </td>
                <td>
                    ~
                </td>
                <td style="width: 110px;">
                    <p style="width: 110px;">
                        @Html.TextBox("EndTime", SearchParma.EndDateTime, new { @class = "date", format = "yyyy-MM-dd HH:mm", @readonly = "true" })
                    </p>
                </td>
                <td align="right">
                    <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="submit" name="submit">
                                            检索</button></div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>
<div class="pageContent">
    @Html.Partial("Buttons")
    <table class="table" width="100%" layouth="115">
        <thead>
            <tr class="header">
                <th>
                    序号
                </th>
                <th>
                    类型
                </th>
                <th>
                    标题
                </th>
                <th>
                    内容
                </th>
               @* <th>
                    接收群
                </th>*@
                <th>
                    创建人
                </th>
                <th>
                    创建时间
                </th>
                <th>
                </th>
            </tr>
        </thead>
        @foreach (var item in Model)
        {
            var action = "email";
            action = item.Type == 2 ? "Email" : (item.Type == 3 ? "SMS" : "Create");
                      
            <tr target="Message_id" rel="@action/@item.ID/@item.GUID" title="@MvcHtmlString.Create(item.Remark)" onclick="Deleting(@item.ID)">
                <td>
                    @i
                </td>
                <td>
                    @{
            var tmpType = AccessCusType.Where(c => c.Value == item.Type.ToString()).FirstOrDefault();
            if (tmpType != null)
            { 
                        @tmpType.Text
            }          
                    }
                </td>
                <td>
                    @item.Title
                </td>
                <td style="width:600px; overflow:hidden">
                    @MvcHtmlString.Create(item.Remark)
                   
                </td>
               @* <td>
                    @item.Receiver
                </td>*@
                <td>
                    @item.Creator
                </td>
                <td>
                    <span formatdate="yyyy-MM-dd HH:mm">
                        @item.CreateTime</span>
                </td>
                <td>
                    @{var reactions = "create";
                      reactions = item.IsCust ? "create" : (item.Type == 2 ? "reEmail" : (item.Type == 3 ? "reSMS" : "create")); //item.Type == 2 ? "reEmail" : (item.Type == 3 ? "reSMS" : "create");
                      var rUpdate =item.IsCust?update:( item.Type == 2 || item.Type == 3 ? reSend : update);
                      var goaction = item.Type == 2 ? "Email" : "SMS";   
                    }
                    @if (rUpdate != null)
                    {
                        <a class="@(rUpdate.CssClass ?? "add")"  href='@rUpdate.Url.Replace("{action}", reactions).Replace("{id}", item.ID.ToString())&OpID=+@rUpdate.ID' target="@(rUpdate.Target ?? "navTab")" title="@rUpdate.Title">
                            <span>@rUpdate.ModuleName</span></a>
                    }
                    &nbsp;
                    @if (!item.IsCust&& goSend != null && (item.Type == 2 || item.Type == 3))
                    { 
                        <a class="@(goSend.CssClass ?? "add")"  href='@goSend.Url.Replace("{action}", goaction).Replace("{id}", item.ID.ToString())&OpID=+@goSend.ID' target="@(goSend.Target ?? "navTab")" title="@goSend.Title">
                            <span>@goSend.ModuleName</span></a>
                    }
                </td>
            </tr>
                    i += 1;
        }
    </table>
</div>
<div class="panelBar">
    <div class="pages">
        <span>共【@ViewData["RowCount"] 】条,每页显示【@SearchParma.Pagination.PageSize】条</span>
    </div>
    <div class="pagination" targettype="navTab" totalcount="@ViewData["RowCount"] "
            numperpage="@ViewData["pageSize"] " pagenumshown="10" currentpage="@Request["pageNum"] ">
    </div>
</div>
